package com.cat.controller;

import com.cat.mybatis.domain.ImgDisplayDO;
import com.cat.mybatis.domain.ImgSourceDO;
import com.cat.service.SpiderService;
import com.cat.service.spi.SpiInterface;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * ？
 *
 * @author xiemh
 * @date 2018/12/13 18:27
 * @since v1.0.0
 */
@RestController
public class TestController {

    @Resource SpiInterface spiSvc;
    @Resource
    SpiderService spiderService;

    @PostMapping("/t1")
    public String t1(){
        return spiSvc.speak();
    }

    @PostMapping("/t2")
    public ImgDisplayDO t2(){
        ImgDisplayDO img = new ImgDisplayDO();
        img.setImgId(1);
        img.setPath("ppppppppp");
        img.setSmallPath("ssssssss");
        return img;
    }

    @PostMapping("/t3")
    public void t3(@RequestBody ImgDisplayDO img){
        if(img!=null){
            System.out.println(img.getPath());
            System.out.println(img.getSmallPath());
        }else {
            System.out.println("nothing");
        }
    }

    @PostMapping("/t4")
    public List<ImgSourceDO> t4(){
        List<ImgSourceDO> page = spiderService.page();
        return page;
    }
}
